#include <stdio.h>
#include<math.h>
#define N 10
int fun(int a[], int b[], int n) {
    int i,n1,n2,n3,n4,n5,s=0;
    for (i = 0; i < n; i++) {
        if (a[i]>999) continue;
      else {n1=a[i];
        n2 = (n1 % 10) * 100 + (n1 / 10 % 10) * 10 + (n1 / 100);
        n3 = fabs (n2 - n1);
        n4 = (n3 % 10) * 100 + (n3 / 10 % 10) * 10 + (n3 / 100);
        n5 = n3 + n4;
        if (n5 == 1089) {
            b[s] = i; 
            s++; }
        }
    }
    
    return(s); 
}

void main() {
    int a[N] = {123, 765, 1, 45, 121, 1345, 131, 67, 696, 3689};
    int i,n,b[N]; 
    n=fun(a,b,N);
   
    for (i = 0; i < n; i++) {
        printf("%5d ", a[b[i]]);
    }
}
